#pragma once
#include <setjmp.h>
#include "..\\LibHaru\\hpdf.h"
#include "PDFCreatorParams.h"
#include "FilerFrogElement.h"

#pragma warning( disable : 4611 ) // warning C4100 : unreferenced formal parameter
#pragma warning( disable : 4100 ) // warning C4100 : unreferenced formal parameter

using namespace std;

static jmp_buf env;

class PDFCreator : FilerFrogElement{
private:
	HPDF_Doc  m_pdf;
	HPDF_Font m_font;
	
	static void error_handler(HPDF_STATUS error_no, HPDF_STATUS detail_no, void *user_data)
	{
		printf("ERROR: error_no=%04X, detail_no=%u\n", (HPDF_UINT)error_no, (HPDF_UINT)detail_no);
		longjmp(env, 1);
	}

	bool DrawPage (const PDFPage& pagedefs);
	bool InitPDFCreator();

public:
	PDFCreator(HWND parent);
	~PDFCreator();

	bool CheckValidPDF(const wstring& fileName);
	bool Go(PDFFile& pdfFile);
};